#ifndef DATASET_H
#define DATASET_H

#include <string>
#include <iostream>
#include <opencv2/opencv.hpp>

#include "util.h"

using namespace std;

struct fincon
{
    string filename;
    int coordinates[6];

    void deserialize(string s)
    {
        vector<string> data = split(s, " ");
        this->filename = data[0];
        for (int i = 0; i < 6; i++)
        {
            coordinates[i] = stoi(data[i + 1]);
        }
    }
};

struct roi
{
    string filename;
    int coordinates[8];

    string serialize()
    {
        char out_buff[1000];

        sprintf(out_buff, "%s %d %d %d %d %d %d %d %d\n", filename.c_str(), coordinates[0], coordinates[1], coordinates[2], coordinates[3], coordinates[4], coordinates[5], coordinates[6], coordinates[7]);
        return out_buff;
    }
};

struct mAP
{
    string filename;
    float AP;

    string serialize()
    {
        char out_buff[10000];

        sprintf(out_buff, "%s %f\n", filename.c_str(), AP);
        return out_buff;
    }
};

struct PALMPRINT
{
    int person_id;
    string filename;
    cv::Mat img;

    PALMPRINT(int pid, string fname, cv::Mat &image) : person_id(pid), filename(fname), img(image){};
    ~PALMPRINT()
    {
        //debug
        //std::cout << "destructing PALMPRINT " << person_id << std::endl;
        img.release();
    };
};

typedef PALMPRINT palmprint;

class Dataset
{
private:
protected:
    virtual int get_person_id(string filename) const = 0;
    string dir;

public:
    Dataset(string dir) : dir(dir){};
    virtual ~Dataset() = 0;
    virtual void load() = 0;

    class iterator
    {
    public:
        iterator(){};
        virtual ~iterator() = 0;

        virtual palmprint &operator*() const = 0;
        virtual palmprint *operator->() const = 0;
        virtual iterator &operator++() = 0;
        virtual iterator &operator++(int) = 0;
        virtual bool operator==(const iterator &arg) const;
        virtual bool operator!=(const iterator &arg) const;
    };
};

#endif
